<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/jsp/commons/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<jsp:include page="/jsp/commons/cssinclude.jsp"></jsp:include>
<jsp:include page="/jsp/commons/scriptinclude.jsp"></jsp:include>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>晶品科技信息管理系统-总经理</title>

</head>
<body>
	<%--<jsp:include page="/jsp/commons/top.jsp"></jsp:include> --%>
	<div class="mainbox">

		<form method="post" action="${ctx}/manager/dispatchAction!add.do"
			id="frmDispatchAdd">
			<input type="hidden" id="hbActionType" value="${actionType}" />
			<div class="main_content">
				<%--<%@include file="/jsp/commons/leftMenu.jsp"%> --%>
				<div class="main_right">
					<!--面包屑 begin-->
					<div class="main_rightbox">
						<div class="ec_crumb_kc">
							<span><a class="icon_up" href="#">上一页</a><a
								class="icon_index" href="#">首页</a></span>当前位置：首页&nbsp;&gt;&nbsp;项目中心&nbsp;&gt;&nbsp;售后部&nbsp;&gt;&nbsp;<em>报修</em>
						</div>
					</div>
					<!--基本信息 begin-->
					<div class="ty_border">
						<div class="ty_head">
							<span class="icon4"></span>甲方资料
						</div>
						<div class="sx_body">
							<dl class="clearfix">
								<dt style="display: none;">甲方资料</dt>

								<dd>
									<label class="name">报修日期：</label><span class="toname"> <input
										type="text" value="" class="Wdate" onClick="WdatePicker()"
										id="repairDate" name="dispatch.repairDate" title="报修日期"
										 
										class="winput3" />
									</span>
									<div class="fl">
										<em id="repairDateTip"></em>
									</div>
								</dd>

								<dd>
									<label class="name">客户名称：</label><span class="toname"> <input
										type="text" value="" id="customerName"
										name="dispatch.customerName" title="商品长标题"
										 
										class="winput3" />
									</span>
									<button class="searchBtn dingwei" type="button" id="btnCustomerName"></button>
									<div class="fl">
										<em id="customerNameTip"></em>
									</div>
								</dd>

								<dd>
									<label class="name">报修联系人：</label> <span class="toname">
										<input type="text" id="repairpeopleName" value=""
										name="dispatch.repairpeopleName" title="报修联系人"
										 
										class="winput3" />
									</span>
									<div class="fl">
										<em id="repairpeopleNameTip"></em>
									</div>
								</dd>

								<dd>
									<label class="name">报修联系电话：</label><span class="toname"><input
										type="text" id="repairPeoplePhone" value=""
										name="dispatch.repairPeoplePhone" title="报修联系电话"
										 
										class="winput3" /></span>
									<div class="fl">
										<em id="repairPeoplePhoneTip"></em>
									</div>
								</dd>

								<dd>
									<label class="name">工程质量保修期限：</label><span class="toname">

										<textarea rows="30" cols="100" id="warrantyPeriod"
											name="dispatch.warrantyPeriod" title="工程质量保修期限"
											 
											class="winput3"></textarea>
									</span>
									<div class="fl">
										<em id="warrantyPeriodTip"></em>
									</div>
								</dd>

								<dd>
									<label class="name">保修情况记录：</label><span class="toname">

										<textarea rows="30" cols="100" id="warranty"
											name="dispatch.warranty" title="保修情况记录"
											 
											class="winput3"></textarea>
									</span>

									<div class="fl">
										<em id="warrantyTip"></em>
									</div>
								</dd>

							</dl>
						</div>
					</div>
					<!--乙方资料 begin-->
					<div class="ty_border">
						<div class="ty_head">
							<span class="icon4"></span>乙方信息
						</div>
						<div class="sx_body">
							<dl class="clearfix">
								<dt style="display: none;">乙方资料</dt>

								<dd>
									<label class="name">路线：</label><span class="toname"> <input
										type="text" value="" id="pathId" name="dispatch.pathId"
										title="路线"  
										class="winput3" />
									</span>
									<button class="searchBtn dingwei" id="btnPathId"></button>
									<div class="fl">
										<em id="pathIdTip"></em>
									</div>
								</dd>

								<dd>
									<label class="name">接单员：</label><span class="toname"> <input
										type="text" value="" id="orderPeople"
										name="dispatch.orderPeople" title="商品长标题"
										 
										class="winput3" />
									</span>
									<button class="searchBtn dingwei" id="btnOrderPeople"></button>
									<div class="fl">
										<em id="orderPeopleTip"></em>
									</div>
								</dd>

								<dd>
									<label class="name">维修技术员：</label> <span class="toname">
										<input type="text" id="maintenanceManId" value=""
										name="dispatch.maintenanceManId" title="维修技术员"
										 
										class="winput3" />
									</span>
									<button class="searchBtn dingwei" id="btnMaintenanceManId"></button>
									<div class="fl">
										<em id="maintenanceManIdTip"></em>
									</div>
								</dd>

								<dd>
									<label class="name">技术员电话：</label><span class="toname"><input
										type="text" id="maintenanceManPhone" value=""
										name="dispatch.maintenanceManPhone" title="商品短标题"
										 
										class="winput3" /></span>
									<div class="fl">
										<em id="maintenanceManPhoneTip"></em>
									</div>
								</dd>

							</dl>
						</div>
					</div>

					<!--项目资料 begin-->
					<div class="ty_border">
						<div class="ty_head">
							<span class="icon4"></span>项目资料
						</div>
						<div class="sx_body">
							<dl class="clearfix">
								<dt style="display: none;">项目资料</dt>

								<dd>
									<label class="name">项目名称：</label><span class="toname"> <input
										type="text" value="" id="name" name="dispatch.name"
										title="项目名称" 
										 class="winput3" />
									</span>
									<div class="fl">
										<em id="nameTip"></em>
									</div>
								</dd>

								<dd>
									<label class="name">是否出库：</label><span class="toname"> <input
										type="text" value="" id="outBound" name="dispatch.outBound"
										title="是否出库" 
										 class="winput3" />
									</span>
									<div class="fl">
										<em id="outBoundTip"></em>
									</div>
								</dd>

								<dd>
									<label class="name">维修单号：</label> <span class="toname">
										<input type="text" id="projectCode" value=""
										name="dispatch.projectCode" title="维修单号"
										 
										class="winput3" />
									</span>
									<div class="fl">
										<em id="projectCodeTip"></em>
									</div>
								</dd>

								<dd>
									<label class="name">维修情况说明：</label><span class="toname">
										<textarea rows="30" cols="100" id="maintenanceInfo"
											name="dispatch.maintenanceInfo" title="维修情况说明"
											 
											class="winput3"></textarea>
									</span>
									<div class="fl">
										<em id="maintenanceInfoTip"></em>
									</div>
								</dd>

							</dl>
						</div>
					</div>

					<!--保存取消 begin-->
					<div class="baocun">
						<button id='btnQuit' type="button" class="gybg qxBtn">取消</button>
						<input type="submit" id="btnAddSave" class="gybg saveBtn"
							value="保存" />
					</div>
				</div>
			</div>
		</form>

	</div>

	<!--客户弹出层 begin-->
	<div id="customerDialog" style="display: none">
		<s:action name="categoryAction!queryCategorySortList"
			executeResult="true" namespace="/category">
		</s:action>

	</div>

	<!-- JQ -->

	<script type="text/javascript">
		//异步加载客户名称
		$("#btnCustomerName").click(function() {
			debugger;
			 $.post(
		     		 "${ctx}/customer/customerAction!initCustomersDialog.action", 
		 				{random:Math.random()}, 
		 				function(data){
		 					$("#customerDialog").html(data);
							//加载弹出层
		 					art.dialog({
		 					    id: 'msg',
		 					    title: '选择属性',
		 					    content: $("#customerDialog").html(),//绑定内容
		 					    ok: function () {
		 					    	 
		 					    },//确定时回调函数
		 					    cancel:true,//取消时回调函数
		 					    lock: true 
		 					});
		 				}
		      
		        );
			
			 
		});

		//根据状态为来决定是增加还是修改
		$("#btnSave")
				.click(
						function() {
							var strActionType = $("#hbActionType").val();
							if (strActionType != "") {
								if (strActionType == 0) {
									//新增操作
									//验证编码
									var vCode = $("#sysparaCode").val();
									if (vCode == "") {
										$("#sysparaCodeTip").html(
												setPrompt("onError",
														"字典编码不能为空，亲输入",
														"${ctx}"));
										$("#sysparaForm").focus();
									} else {
										if (codeValidator($("#sysparaCode")
												.val(), "N")) {
											$("#sysparaForm")
													.attr("action",
															"${ctx}/syspara/sysparaAction!addSyspara.action");
											$("#sysparaForm").submit();
										} else {
											$("#sysparaForm").focus();
										}
									}
								} else if (strActionType == 1) {
									//修改操作
									$("#sysparaForm")
											.attr("action",
													"${ctx}/syspara/sysparaAction!updateSyspara.action");
									$("#sysparaForm").submit();
								} else {
									alert("系统错误，请联系系统管理员！");
								}
							} else {
								alert("系统错误，请联系系统管理员！");
							}
						});

		/**
		 * 验证编码
		 * @param code 编码
		 * @param flag 是否异步
		 */
		function codeValidator(code, flag) {
			var result = false;
			//异步验证
			if (flag == "Y") {
				$.post("${ctx}/syspara/sysparaAction!codeValidator.action", {
					random : Math.random(),
					"syspara.code" : code
				}, function(data) {
					var jsonData = strToJson(data);
					if (jsonData.flag == "success") {
						$("#sysparaCodeTip")
								.html(
										setPrompt("onSuccess", jsonData.data,
												"${ctx}"));
						result = true;
					} else {
						$("#sysparaCodeTip").html(
								setPrompt("onError", jsonData.errorMsg,
										"${ctx}"));
					}
				});
			} else {
				//同步验证
				var url = "${ctx}/syspara/sysparaAction!codeValidator.action";
				var params = {
					"random" : Math.random(),
					"syspara.code" : code
				};
				$.ajax({
					url : url,
					type : 'post',
					data : params,
					async : false,
					dataType : 'json',
					success : function(data) {
						var jsonData = strToJson(data);
						if (jsonData.flag == "success") {
							$("#sysparaCodeTip").html(
									setPrompt("onSuccess", jsonData.data,
											"${ctx}"));
							result = true;
						} else {
							$("#sysparaCodeTip").html(
									setPrompt("onError", jsonData.errorMsg,
											"${ctx}"));
						}
					},
					error : function() {
						alert("系统错误");
						queryCategory();
					}
				});
			}
			return result;
		}

		/**
		 *绑定值改变事件
		 */
		$("#sysparaCode").change(
				function() {
					$("#sysparaCodeTip").html(
							setPrompt("onLoad", "正在验证数据，请稍等", "${ctx}"));
					codeValidator($("#sysparaCode").val(), "Y");
				});

		$(".ctnGdpOptionPanel li").hover(function() {
			$(this).addClass("hover");
		}, function() {
			$(this).removeClass("hover");
		});
		$(".arrowname").click(function() {
			var domUl = $(this).parent().find(".ctnGdpOptionPanelMask");
			var domArrow = $(this).find("span.arrowdown");
			if (domArrow.hasClass("arrowUp")) {
				domArrow.removeClass("arrowUp");
				domUl.show();
			} else {
				domArrow.addClass("arrowUp");
				domUl.hide();
			}
		});
		
		//取消事件
		$("#btnQuit").click(function(){
			art.dialog.confirm('你确认放弃页面操作，返回列表？', function(){
				location.href ="${ctx}/manager/managerAction!listInit.action";
			}, function(){
			     
			});
		});
	</script>
</body>
</html>